{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# New in Forest 2 - Parametric Programs\n",
    "\n",
    "pyQuil is for constructing and running hybrid quantum/classical algorithms on real quantum computers. With the release of pyQuil 2, we have changed parts of the API to take advantage of some exciting new features available on QCS.\n",
    "\n",
    "A hybrid algorithm involves using the quantum computer to create a quantum state that would be difficult to prepare classically; measure it in a way particular to your problem; and then update your procedure for creating the state so that the measurements are closer to the correct answer. A *real* hybrid algorithm involves structured ansatze like QAOA for optimization or a UCC ansatz for chemistry. Here, we'll do a much simpler parameterized program"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "RY(0.2) 0\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from pyquil import Program, get_qc\n",
    "from pyquil.gates import *\n",
    "\n",
    "def ansatz(theta):\n",
    "    program = Program()\n",
    "    program += RY(theta, 0)\n",
    "    return program\n",
    "\n",
    "print(ansatz(theta=0.2))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Scan over the parameter (the old way)\n",
    "\n",
    "For this extrordinarily simple ansatz, we can discretize the parameter theta and try all possible values. As the number of parameters increases, the number of combinations increases exponentially so doing a full grid search will become intractable for anything more than ~two parameters."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "qc = get_qc(\"9q-square-qvm\")\n",
    "\n",
    "thetas = np.linspace(0, 2*np.pi, 21)\n",
    "results = []\n",
    "for theta in thetas:\n",
    "    program = ansatz(theta)\n",
    "    bitstrings = qc.run_and_measure(program, trials=1000)\n",
    "    results.append(np.mean(bitstrings[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZcAAAESCAYAAAAxG5hmAAAABHNCSVQICAgI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K5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "plt.plot(thetas, results, 'o-')\n",
    "plt.xlabel(r'$\\theta$', fontsize=18)\n",
    "_ = plt.ylabel(r'$\\langle \\Psi(\\theta) | \\frac{1 - Z}{2} | \\Psi(\\theta) \\rangle$',\n",
    "               fontsize=18)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Do an optimization (the old way)\n",
    "\n",
    "Instead of doing a full grid search, we will employ a classical optimizer to find the best parameter values. Here we use scipy to find the theta that results in sampling the most `1`s in our resultant bitstrings."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "     fun: -1.0\n",
       "   maxcv: 0.0\n",
       " message: 'Optimization terminated successfully.'\n",
       "    nfev: 13\n",
       "  status: 1\n",
       " success: True\n",
       "       x: array([3.1])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def objective_function(theta):\n",
    "    program = ansatz(theta[0])\n",
    "    bitstrings = qc.run_and_measure(program, trials=1000)\n",
    "    result = np.mean(bitstrings[0])\n",
    "    return -result\n",
    "\n",
    "import scipy.optimize\n",
    "res = scipy.optimize.minimize(objective_function, x0=[0.1], method='COBYLA')\n",
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x1015dedf28>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAA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+ltgltZ6vtF5aqr81+ifgYEGR6mOXsDQ8nPWc4D+SqkvjY1UfVrrzPJ/ZgELsJxydSQZQEaF3/rmYSl7u+Fo5W7NzbpFLSq/IPkpsEdr/ZrReapLKRWglPIt/9gTuAHYa2wq62mtH9dah2qtw7D8/V+ltb7b4FjVopRqWH4xnvJTGTcBDrV7TGt9DDislGpT/qkBgF1tKnCoOzFd7mbdBseqFqXUbKAv4K+UygCe1Vp/amyqaukF3APsKj9vDfCE1nqJgZmqoxnw3/KdVybga621Q24ndGBBwILy+/O6Al9prZcaG6lGHgRmlS80DwATDM7zBw61FVIIIYR1HO20jBBCCCtIuQshhBOSchdCCCck5S6EEE5Iyl0IIZyQlLsQQjghKXchhHBCUu5CCOGE/h/cf2E71T9+6gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(thetas, results, label='scan')\n",
    "plt.plot([res.x], [-res.fun], '*', ms=20, label='optimization result')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Compilation\n",
    "\n",
    "Prior to QCS, a QPU job would be routed via a series of cloud-based queues and compilation steps. With Forest 2, you are in control of the two stages of compilation so you can amortize the cost of compiling. Your QMI and all classical infrastructure is hosted on the Rigetti premises, so network latency is minimal.\n",
    "\n",
    "### Quil to native quil\n",
    "\n",
    "The first step of compilation converts gates to their hardware-supported equivalent. For example, our parametric RY is converted into RX's and RZ's because these are physically realizable on a Rigetti QPU"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PRAGMA EXPECTED_REWIRING \"#(0 1 2 3 4 5 6 7 8)\"\n",
      "RX(pi/2) 0\n",
      "RZ(0.5) 0\n",
      "RX(-pi/2) 0\n",
      "PRAGMA CURRENT_REWIRING \"#(0 1 2 3 4 5 6 7 8)\"\n",
      "PRAGMA EXPECTED_REWIRING \"#(0 1 2 3 4 5 6 7 8)\"\n",
      "PRAGMA CURRENT_REWIRING \"#(0 1 2 3 4 5 6 7 8)\"\n",
      "\n"
     ]
    }
   ],
   "source": [
    "nq_program = qc.compiler.quil_to_native_quil(ansatz(theta=0.5))\n",
    "print(nq_program)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Native quil to executable\n",
    "\n",
    "The second step of compilation will turn named gates into calibrated pulses stored in a binary format suitable for consumption by the control electronics. This means that you can fully compile a given program and run it many times with minimal classical overhead.\n",
    "\n",
    "**Note:** since we're using a QVM, for which there is no binary format, this stage is mocked out and you can see the original Quil inside the `PyQuilExecutableResponse` that is returned. When running on the QPU, this will return a `BinaryExecutableResponse` whose contents are opaque. \n",
    "\n",
    "**TODO:** obscure the contents of `PyQuilExecutableResponse`: https://github.com/rigetti/pyquil/issues/700"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PyQuilExecutableResponse(attributes={'native_quil_metadata': {'final-rewiring': [0, 1, 2, 3, 4, 5, 6, 7, 8], 'topological_swaps': 0, 'gate_depth': 3, 'gate_volume': 3, 'program_duration': 18.01, 'program_fidelity': 1.0, 'multiqubit_gate_depth': 0}, 'num_shots': 1}, program='PRAGMA EXPECTED_REWIRING \"#(0 1 2 3 4 5 6 7 8)\"\\nRX(pi/2) 0\\nRZ(0.5) 0\\nRX(-pi/2) 0\\nPRAGMA CURRENT_REWIRING \"#(0 1 2 3 4 5 6 7 8)\"\\nPRAGMA EXPECTED_REWIRING \"#(0 1 2 3 4 5 6 7 8)\"\\nPRAGMA CURRENT_REWIRING \"#(0 1 2 3 4 5 6 7 8)\"\\n')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "qc.compiler.native_quil_to_executable(nq_program)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Parametric compilation\n",
    "This doesn't buy us much if we have to know exactly what circuit we want to run before compiling it and amortizing the compilation cost. Maybe you could get away with it when you're doing a parameter scan, but for hybrid algorithms, the circuit parameter (here: `theta`) depends on the results of a circuit before. This is the essence of hybrid programming! Therefore, all compilation steps have been upgraded to support named, symbolic parameters that will be updated at runtime with minimal overhead.\n",
    "\n",
    "With this feature, you can compile a parametric program once and run it many times will different parameter values *and* you need not know the parameter values at compilation time.\n",
    "\n",
    "There are a couple of prerequisites to use this feature effectively from PyQuil, which we address in this document.\n",
    "\n",
    "First, you must declare a parameter when constructing your quil program. When declaring a named classical variable, you must specify at least a name and a type. It is conventional to make sure the Python variable name of the reference memory matches the Quil variable name. In our case, we name both things `theta`. Our circuit above would be modified in this way:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DECLARE theta REAL[1]\n",
      "RY(theta) 0\n",
      "\n"
     ]
    }
   ],
   "source": [
    "program = Program()\n",
    "theta = program.declare('theta', memory_type='REAL')\n",
    "program += RY(theta, 0)\n",
    "print(program)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Measuring\n",
    "\n",
    "In the documentation so far, we've been using the `run_and_measure` functionality of `QuantumComputer`. It's time to get our hands dirty and introduce explicit measure instructions. \n",
    "\n",
    "Above, we declared a classical piece of memory, we've given it a name (`theta`), and we've given it a type (`REAL`). The bits that we measure (or \"read out\" -- `ro` for short) must now also be declared, given a name, and a type. Additionally, we'll usually be measuring more than one qubit so we can give this register a size.\n",
    "\n",
    "The index of the readout register need not match the qubit index. For example below, we create a bell state on qubits 5 and 6 and measure the readout results into `ro[0]` and `ro[1]`.\n",
    "\n",
    "**Note:** The readout register must be named \"ro\" (for now)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DECLARE ro BIT[2]\n",
      "H 5\n",
      "CNOT 5 6\n",
      "MEASURE 5 ro[0]\n",
      "MEASURE 6 ro[1]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "program = Program()\n",
    "ro = program.declare('ro', memory_type='BIT', memory_size=2)\n",
    "program += H(5)\n",
    "program += CNOT(5, 6)\n",
    "program += MEASURE(5, ro[0])\n",
    "program += MEASURE(6, ro[1])\n",
    "print(program)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Our very simple ansatz only has one qubit, so the measurement is quite simple."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DECLARE theta REAL[1]\n",
      "DECLARE ro BIT[1]\n",
      "RY(theta) 0\n",
      "MEASURE 0 ro[0]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "program = Program()\n",
    "theta = program.declare('theta', memory_type='REAL')\n",
    "ro = program.declare('ro', memory_type='BIT', memory_size=1)\n",
    "program += RY(theta, 0)\n",
    "program += MEASURE(0, ro[0])\n",
    "print(program)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Number of shots\n",
    "The number of trials is compiled into the executable binary, so we must specify this number *prior* to compilation. \n",
    "\n",
    "**TODO: add to str / repr** https://github.com/rigetti/pyquil/issues/701"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DECLARE theta REAL[1]\n",
      "DECLARE ro BIT[1]\n",
      "RY(theta) 0\n",
      "MEASURE 0 ro[0]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "program = Program()\n",
    "theta = program.declare('theta', memory_type='REAL')\n",
    "ro = program.declare('ro', memory_type='BIT', memory_size=1)\n",
    "program += RY(theta, 0)\n",
    "program += MEASURE(0, ro[0])\n",
    "program.wrap_in_numshots_loop(shots=1000)\n",
    "print(program)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Using `qc.run()`\n",
    "\n",
    "To use the lower-level but more powerful `qc.run` interface, we have had to take control of these three things\n",
    "\n",
    " 1. We decalred a read-out register named `ro` of type `BIT` and included explicit `MEASURE` instructions. Since this sets up a (potentially sprase) mapping from qubits to classical addresses, we can expect `qc.run()` to return the classic 2d ndarray of yore instead of the dictionary returned by `run_and_measure`\n",
    " 2. We have called `program.wrap_in_numshots_loop()` prior to compilation so the number of shots can be encoded in an efficient binary representation of the program\n",
    " 3. We have taken control of compilation; either by calling `qc.compile(program)` or by using the lower-level functions:\n",
    "   ```\n",
    "   nq_program = qc.compiler.quil_to_native_quil(program)\n",
    "   executable = qc.compiler.native_quil_to_executable(nq_program)\n",
    "   ```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DECLARE ro BIT[1]\n",
      "RY(pi) 0\n",
      "MEASURE 0 ro[0]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "def ansatz(theta):\n",
    "    program = Program()\n",
    "    ro = program.declare('ro', memory_type='BIT', memory_size=1)\n",
    "    program += RY(theta, 0)\n",
    "    program += MEASURE(0, ro[0])\n",
    "    return program\n",
    "\n",
    "print(ansatz(theta=np.pi))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can run the program with a pre-set angle (here, `theta = np.pi`)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5, 1)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1],\n",
       "       [1]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "program = ansatz(theta=np.pi)\n",
    "program.wrap_in_numshots_loop(shots=5)\n",
    "executable = qc.compile(program)\n",
    "bitstrings = qc.run(executable)\n",
    "print(bitstrings.shape)\n",
    "bitstrings"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Scan over the parameter (the new way)\n",
    "\n",
    "Finally, all the pieces are in place to compile and run parameterized executable binaries. \n",
    "We declare parameters that will be compiled symbolically into the binary allowing us to amortize the cost of compilation when running hybrid algorithms."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DECLARE theta REAL[1]\n",
      "DECLARE ro BIT[1]\n",
      "RY(theta) 0\n",
      "MEASURE 0 ro[0]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "def ansatz():\n",
    "    program = Program()\n",
    "    theta = program.declare('theta', memory_type='REAL')\n",
    "    ro = program.declare('ro', memory_type='BIT', memory_size=1)\n",
    "    program += RY(theta, 0)\n",
    "    program += MEASURE(0, ro[0])\n",
    "    return program\n",
    "\n",
    "print(ansatz())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Using `memory_map`\n",
    "Now, when we call `qc.run` we provide a `memory_map` argument which will substitute in values for previously-declared Quil variables in a pre-compiled executable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZcAAAESCAYAAAAxG5hmAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAIABJREFUeJzt3Xd8lfX5//HXlUkII4wwEkYYIcoQkIgglqUFVxX5uqvW0aIiWq3SSq221VpUrNaJWrSiVlsHIiIaB0MZyjCyCYSdhBFGWNnJ9fvjH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>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "program = ansatz()  # look ma, no arguments!\n",
    "program.wrap_in_numshots_loop(shots=1000)\n",
    "executable = qc.compile(program)\n",
    "\n",
    "thetas = np.linspace(0, 2*np.pi, 21)\n",
    "results = []\n",
    "for theta in thetas:\n",
    "    bitstrings = qc.run(executable, memory_map={'theta': [theta]})\n",
    "    results.append(np.mean(bitstrings[:, 0]))\n",
    "    \n",
    "%matplotlib inline\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "plt.plot(thetas, results, 'o-')\n",
    "plt.xlabel(r'$\\theta$', fontsize=18)\n",
    "_ = plt.ylabel(r'$\\langle \\Psi(\\theta) | \\frac{1 - Z}{2} | \\Psi(\\theta) \\rangle$', fontsize=18)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Do an optimization (the new way)\n",
    "\n",
    "Since parameters are compiled symbolically, we can do hybrid algorithms just as fast as parameter scans. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "     fun: -1.0\n",
       "   maxcv: 0.0\n",
       " message: 'Optimization terminated successfully.'\n",
       "    nfev: 12\n",
       "  status: 1\n",
       " success: True\n",
       "       x: array([3.1])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "program = ansatz()  # look ma, no arguments!\n",
    "program.wrap_in_numshots_loop(shots=1000)\n",
    "executable = qc.compile(program)\n",
    "\n",
    "def objective_function(thetas):\n",
    "    bitstrings = qc.run(executable, memory_map={'theta': thetas})    \n",
    "    result = np.mean(bitstrings[:, 0])\n",
    "    return -result\n",
    "\n",
    "res = scipy.optimize.minimize(objective_function, x0=[0.1], method='COBYLA')\n",
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x1015f13898>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAIABJREFUeJzt3XlcVXX+x/HX97LIIqAiKIoCCiqIC4jmrmi2qGWLLZaNOqUtajOtU9NU0zIz/aaZatJ2K8sWbRnLzMrc9wV3BQUURMQFURFBtnu/vz9AhxDlghfOXT7Px8OH3HvPvfd9Fd5+Ped7vkdprRFCCOFcTEYHEEIIYXtS7kII4YSk3IUQwglJuQshhBOSchdCCCck5S6EEE5Iyl0IIZyQlLsQQjghKXchhHBC7ka9ccuWLXV4eLhRby/Eb2kLnM6CZu1ByZhH2K8tW7ac0FoH1badYeUeHh5OUlKSUW8vxG/t/RHm3gV3vgxdRhqdRohLUkodtGY7GaIIAZDyw29/F8LBSbkLoTWk/lLxderPFbeFcHBS7kLk7oXy4oqvy4shd5+xeYSwASl3IVIXg8Vc8bU2Q9piY/MIYQNS7kIkzwdzScXX5SWwZ76xeYSwgVpnyyilPgJGA8e11rE1PK6A/wAjgSJgotZ6q62DClFv88Zf/kCpm+dvbx/bDX8NuPT20TfAHZ/ZJpsQDcSakfts4LrLPH49EFX5awrwzpXHEsKGrn4BWncDD5+aHzeXXv72eR4+0Lp7xesJYedqLXet9Srg5GU2GQN8qitsAJoppUJsFVCIKxbYEaashMQ/g7t33U9SUqaK5yU+U/E6gR0bJqcQNmSLfe5tgUNVbmdX3ncRpdQUpVSSUiopNzfXBm8thJVMbtB/Ojy4Flp1vfQovppSkxfnWkSjH1gD/aeBSQ5TCcdgi+9UVcN9NU4U1lq/r7VO0FonBAXVevasELYX2BE9eQVHu0+l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bHu9vzPesW+44blsFfJyckX32ku13rtm1q/1ErrvzbT+nl/63/9tVnF89bO0NpsrvX9k5KSdGxsrD579qwuKCjQMTExeuvWrTojI0MDes2aNVprrSdNmqRfffVVrbXWYWFhOjc398JrnL+dkZGh3dzc9M6dO7XZbNbx8fF60qRJ2mKx6O+++06PGTNGa631xx9/rKdOnfqbHAsWLNADBw7UpaWlOj8/X5eVlWmttf7111/1LbfcUuPzqt4ePXq0nj17ttZa6w8//PDCe02YMEGPHTtWm81mvWfPHt2xY8eL/gwyMjK0UkqvX79ea611bm6uHjRokD579qzWWutXXnlFv/DCCzovL0936tRJWywWrbXWp06duvAeX3/99YXX8/X1vfC6Xbt2veRnPq/G7wEXty79hO710mId/exP+rtt2dpsthiSA0jSVnSsS43cS8stzFmfyfhZG2nm48F3UwcwRE5Mso7JDfpPhwfXQquulx7FV+fhA61iK57XfxpYsWthzZo13Hzzzfj6+tK0aVNuueUWVq9eDUC7du0YMGAAAOPHj2fNmjW1vl5ERATdunXDZDLRtWtXhg8fjlKKbt26XXIp4LS0NJ544gnmzZuHh4cH+fn53HbbbcTGxvLII4+wZ8+eWt93/fr13HXXXQDcc889v8l60003YTKZiImJ4dixYzU+PywsjL59+wKwYcMGkpOTGTBgAD179uSTTz7h4MGD+Pv74+XlxX333cd///tffHys/HsRddavYyALpw8iOsSfP8zdTp+/L+Wxr3bww44c8ovs7+xWqxYOU0pdB/wHcANmaa1fqfZ4E+BToBeQB9yhtc60bdS6O5pfzNasU2w9eIpth06z63A+peUWEjsH8Z9xcTJ/vT4CO8KUlbDmdVj16v+mQNbE3QsGPQYDH7Wq1M/TlzkOVH39D2vWA6m6/K/JZLpw22Qy1bgUcGFhIbfffjsffPABbdq0AeDZZ58lMTGR+fPnk5mZydChQ635KJfMWjXTpT5v1YXQtNaMGDGCL7/88qLtNm3axNKlS5k7dy4zZ85k2bJluLu7Y7FYLjy3tPQyx0CE1VoHePHl5L78uCuHZXtzWbr3GN9uzcakIK59c4Z2CmJo52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SoUDccBGY5PUTeUuje3AceBXrbVD5QfeAJ4ELLVtaMc0sFgptaXy2sqOpgOQC3xcuXtsllLK1+hQVTlauVt1IW7R8JRSTYFvgT9qrc8YnacutNZmrXVPKq4H3Ecp5TC7x5RSo4HjWustRme5QgO01vHA9cDUyt2VjsQdiAfe0VrHAYWAXR0DdLRyt+Zi3aKBVe6r/hb4XGv9X6Pz1Fflf6NXANcZHKUuBgA3Vu6zngsMU0p9ZmykutNa51T+fhyYT8UuV0eSDWRX+V/fN1SUvd1wtHK35mLdogFVHpD8EEjRWr9mdJ66UkoFKaWaVX7tDVwN7DU2lfW01k9rrUO11uFUfP8v01qPNzhWnSilfCsPxlO5K+MawKFmj2mtjwKHlFKdK+8aDtjVpAKHuhLTpS7WbXCsOlFKfQkMBVoqpbKB57XWHxqbqk4GAPcAuyr3WwP8WWu9yMBMdRECfFI588oEfKW1dsjphA6sFTC/8vq87sAXWuufjY1UL9OBzysHmgeASQbn+Q2HmgophBDCOo62W0YIIYQVpNyFEMIJSbkLIYQTknIXQggnJOUuhBBOSMpdCCGckJS7EEI4ISl3IYRwQv8P7H1XxHAmczEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(thetas, results, label='scan')\n",
    "plt.plot([res.x], [-res.fun], '*', ms=20, label='optimization result')\n",
    "plt.legend()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
